#!/bin/bash

g="g08"

if [ "$1" = "" ]
then
	echo "Informe diretorio"
	exit
fi

mkdir -p "$1/$g/out$2"

for i in $(ls "$1/in$2/")
do
	f="$1/in$2/$i"
	if [ -f $f ]
	then
		echo "Running $i"
		rm -f minijava.asm
		rm -f minijava

		p=${i::$[$[${#i} -5]]}

		./run.sh < $f
		cp minijava.asm "$1/$g/out$2/$p.asm"
		cp minijava "$1/$g/out$2/"$p
		echo ""
	fi
done

